package com.wilson.integration.lease.admin.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wilson.integration.lease.common.entity.SystemPost;
import com.wilson.integration.lease.common.entity.SystemUser;
import com.wilson.integration.lease.common.entity.vo.system.user.SystemUserItemVO;
import com.wilson.integration.lease.common.entity.vo.system.user.SystemUserQueryVO;
import com.wilson.integration.lease.common.mapper.SystemPostMapper;
import com.wilson.integration.lease.common.mapper.SystemUserMapper;
import com.wilson.integration.lease.admin.service.SystemUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
 * @author wilson
 * @description 针对表【system_user(员工信息表)】的数据库操作Service实现
 * @createDate 2023-07-24 15:48:00
 */
@Service
public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemUser> implements SystemUserService {

    @Resource
    private SystemUserMapper systemUserMapper;

    @Resource
    private SystemPostMapper systemPostMapper;

    @Override
    public IPage<SystemUserItemVO> pageSystemUserByQuery(IPage<SystemUser> page, SystemUserQueryVO queryVO) {
        return systemUserMapper.pageSystemUserByQuery(page, queryVO);
    }

    @Override
    public SystemUserItemVO getSystemUserById(Long id) {
        SystemUser systemUser = systemUserMapper.selectById(id);
        SystemPost systemPost = systemPostMapper.selectById(systemUser.getPostId());
        SystemUserItemVO systemUserItemVO = new SystemUserItemVO();
        BeanUtils.copyProperties(systemPost, systemUserItemVO);
        systemUserItemVO.setPostName(systemUserItemVO.getPostName());
        return systemUserItemVO;
    }
}




